<template>
  <div class="demo-collapse">
    <el-collapse v-model="activeNames" @change="handleChange">
      <el-collapse-item
        v-for="item in checkOptions"
        :key="item.id"
        :title="item.checkName"
        :name="item.key"
      >
        {{ item.checkResult }}
      </el-collapse-item>
    </el-collapse>
  </div>
</template>

<script>
import request from "@/utils/forward/request";
export default {
  data() {
    return {
      checkOptions: [],
    };
  },
  methods: {},

  mounted() {
    // 获取检查结果
    // 从vuex中获取检查ID
    const examinationId = this.$store.state.doctorOptions.examinationId;
    // 通过检查ID获取所有检查项以及结果，没有结果的写上暂无结果
    request("get", "checkItem/getCheckResultInfo", {
      checkId: examinationId,
    }).then((res) => {
      console.log(res.result);
      const checkOptionList = res.result.map((e) => {
        return {
          id: e.ID,
          key: e.CHECK_CODE,
          checkName: e.NAME + "-" + e.PART,
          checkResult: e.RESULT == null ? "暂无结果" : e.RESULT,
        };
      });
      this.checkOptions = checkOptionList;
    });
  },
};
</script>

<style>
.demo-collapse {
  width: 100%;
  height: 50%;
}
</style>
